﻿using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YZQ_DotNetArx.CAD
{
    public class Interactive
    {
        public double GetWidth()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //定义一个实数的交互类
            PromptDoubleOptions optDou=new PromptDoubleOptions("\n请输入线宽");
            optDou.AllowNegative = false; //不允许输入负数
            optDou.DefaultValue = 0; //设置默认值为0
            PromptDoubleResult resDou = ed.GetDouble(optDou);
            if (resDou.Status==PromptStatus.OK)
            {
                double width=resDou.Value;  
                return width; //得到用户输入的线宽
            }
            else
                return 0;   
        }
        public short GetColorIndex()
        { 
            Editor ed=Application.DocumentManager.MdiActiveDocument.Editor;
            //定义一个整数的用户交互类
            PromptIntegerOptions optInt = new PromptIntegerOptions("\n请输入颜色索引（0~265）");
            optInt.DefaultValue= 0; //设置默认值
            //返回一个整数提示类
            PromptIntegerResult resInt=ed.GetInteger(optInt);
            if (resInt.Status==PromptStatus.OK)
            {
                //得到用户输入的颜色索引值
                short colorIndex=(short)resInt.Value;
                if (colorIndex > 256 | colorIndex < 0)
                    return 0;
                else
                    return colorIndex;
            }
            else
                return 0;
        }
    }
}
